<?php
namespace Admin\Controller;
use Think\Controller;
class CLubLessonController extends BaseController {
   public function clessonlist(){
        $videosModel=M('club_lesson'); //实例化模型对象 user 表名
		$videos=$videosModel->order('club_lesson_id desc')->select(); //查询
		$this->videos=$videos; //volist name
		// dump ($users); 
		$this->display();
}
 public function clessondel(){
        // dump($_GET);
        $videoModel=M('club_lesson');
        $vid=$_GET['vid'];
        var_dump($vid);
        $res=$videoModel->where("club_lesson_id=$vid")->find();
        //var_dump($res);
        if ($videoModel->where("club_lesson_id=$vid")->delete()) {
        	$this->success('删除成功');
        }else{
        	$this->error('删除失败');
        }

    }
    public function addclesson(){   
  
        $videos = D('club_lesson'); 
        $data['club_lesson_name']=I('post.lessonname');
        $data['club_lesson_intro']=I('post.lessonintro');
        $data['club_lesson_begin']=I('post.lessonbegin');
        $data['club_lesson_over']=I('post.lessonover');
        $data['club_lesson_price']=I('post.lessonprice');
        $data['club_lesson_date']=date('Y-m-d H:i:s');
        $data['club_id']=S('club_id');
        dump($data);
        
         if(false!==$videos->add($data)){
             $this->success('成功','clessonlist');
         }else{
            $this->error('失败');
         }
        }//register end
     public function editvideos(){
      
        $videos = D('club_lesson'); 
        $vid=I('post.id');
        $data['club_lesson_name']=I('post.lessonname');
        $data['club_lesson_intro']=I('post.lessonintro');
        $data['club_lesson_begin']=I('post.lessonbegin');
        $data['club_lesson_over']=I('post.lessonover');
        $data['club_lesson_price']=I('post.lessonprice');
        $data['club_lesson_date']=date('Y-m-d H:i:s');
        $data['club_id']=S('club_id');
        dump($data);
        if(false !== $videos->where("club_lesson_id=$vid")->save($data)){
            $this->success('成功','clessonlist');
         }else{
            $this->error('失败');
         }

        }//register end
    public function clessonedit(){    
            $videos = M('club_lesson'); 
            $vid=$_GET['id'];
            $res=$videos->where("club_lesson_id=$vid")->find();
            $this->videos=$res;
         
        $this->display();
        }



    public function MyUpload(){
    $upload = new \Think\Upload();// 实例化上传类
    $upload->maxSize   =     3145728 ;// 设置附件上传大小
    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
    $upload->rootPath  =     './Public/Uploads/videophoto/'; // 设置附件上传根目录
    $upload->autoSub   = false;//关闭子目录，默认ture
    //$info=$upload->uploadOne($_FILES['file']);  //上传文件

    //$upload->savePath  =     ''; // 设置附件上传（子）目录
    $upload->savename = 'time';

    $info   =   $upload->upload();  // 上传文件 
    //$dump(info);
    if(!$info) {        $this->error($upload->getError());    }
    else{return $info;}
    
    // else{        $this->success('上传成功！');    }  


    } //MyUpload end

}